(function(){

var defaultOptions = {
    defaultValue: '#Emin'
};
$.fn.chrod = function(options){
    var _t = this;
    options = $.extend({}, defaultOptions, options);
    //当前值
    var value;

    this.setValue = function(val){
        if(val === value) return;
        value = val;
        requestAnimationFrame(function(){
            var array;
            val.replace(/(#|b)?([A-G])(min|maj)?/, function(str, a, b, c){
                array = [a, b, c];
            });
            var background = array.map(function(item){
                    item = item || 'n';
                    if(item === '#') item = 's';
                    if(item === 'b') item = 'bs';
                    item = item.toLowerCase();

                    return 'url(./images/chrod-name-' + item + '.png)';
                }).join(',');
            _t.css('background-image', background);
        });
    };

    this.setValue(options.defaultValue);
    return this;
};

})();